package com.bena.udvtui2;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.location.LocationManager;
import android.util.Log;
import android.view.View;
import android.widget.Button;


public class ProximityAlertReceiver extends BroadcastReceiver {

	
	public static final String EVENT_ID_INTENT_EXTRA = "EventIDIntentExtraKey";
	
	@Override
	public void onReceive(Context context, Intent intent) {
		String key = LocationManager.KEY_PROXIMITY_ENTERING;
		Boolean entering = intent.getBooleanExtra(key, false);
		
		long eventID = intent.getLongExtra(EVENT_ID_INTENT_EXTRA, -1);
		String name = intent.getStringExtra("name");
		
		if(entering){
			Log.i("UDVT2","Proximity Alert Intent Received, eventID = "+eventID+" "+name);
			ShowMap.proxName=name;
			ShowMap.goInfoButton.setVisibility(View.VISIBLE);
			
			// This strategy works
			// However I think it should suffice to just do context.startActivity(intent) <-- original intent
			// And then in the manifest file for the activity to start it should have the string in there
			
			//Intent intent1 = new Intent(Intent.ACTION_DIAL);
			//context.startActivity(intent);
			
			//The intent has a action of PROXIMITY_INTENT_ACTION. So does WiFiFun
			//context.startActivity(intent);
		}
		else{
			Log.i("UDVT2","Leaving eventID = "+eventID+" "+name);
			ShowMap.proxName=null;
			ShowMap.goInfoButton.setVisibility(View.INVISIBLE);
		}
	}

}
